import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr";

const isProd = process.env.NODE_ENV === "production";

export default defineConfig({
  define: {
    __DEV__: !isProd,
  },
  plugins: [
    react({ jsxRuntime: "automatic" }),
    svgr({
      include: "**/*.svg?jsx",
      svgrOptions: {
        svgoConfig: {
          plugins: [
            {
              name: "preset-default",
              params: {
                overrides: {
                  // viewBox is required to resize SVGs with CSS.
                  // @see https://github.com/svg/svgo/issues/1128
                  removeViewBox: false,
                },
              },
            },
          ],
        },
      },
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve(process.cwd(), "src"),
    },
  },
  server: {
    proxy: {
      "/mrgf": "https://names.library.sh.cn",
      // "/np": "http://192.168.1.107:8000",
      "/llm": "https://names.library.sh.cn",
      // "/np": "http://10.1.30.72:8088",
      // "/llm": "http://127.0.0.1:8888",
    },
  },
  base: "/ainianpu",
});
